package com.app.twth.ui.b2bpick;


import com.app.twth.app.Constant;
import com.app.twth.base.BaseModel;
import com.app.twth.bean.BaseResponseEntity;
import com.app.twth.net.JsonCallBack;
import com.app.twth.ui.b2cpick.submit.B2CPickSubmitQr;
import com.app.twth.utils.GsonUtil;
import com.lzy.okgo.OkGo;

import java.util.HashMap;
import java.util.Map;

public class B2BPickDataModel extends BaseModel {
    public <T> void b2bPickPendingJobs(JsonCallBack jsonCallBack) {
        OkGo.<BaseResponseEntity<T>>get(Constant.b2bPickPendingJobs)
                .tag(this)
                .execute(jsonCallBack);
    }

    public <T> void b2bPickCheckPickNo(String pickNo, JsonCallBack jsonCallBack) {
        OkGo.<BaseResponseEntity<T>>get(Constant.b2bPickCheckPickNo + "/" + pickNo)
                .tag(this)
                .execute(jsonCallBack);
    }

    public <T> void b2bPickItems(String pickNo, JsonCallBack jsonCallBack) {
        OkGo.<BaseResponseEntity<T>>get(Constant.b2bPickItems + "/" + pickNo)
                .tag(this)
                .execute(jsonCallBack);
    }

    public <T> void b2bPickCompleted(String pickNo, JsonCallBack jsonCallBack) {
        OkGo.<BaseResponseEntity<T>>put(Constant.b2bPickCompleted + "/" + pickNo)
                .tag(this)
                .execute(jsonCallBack);
    }

    public <T> void b2bPickCheckIbLpn(String ibLpn, String pickNo, JsonCallBack jsonCallBack) {
        Map<String, String> map = new HashMap<>();
        map.put("ibLpn", ibLpn);
        map.put("pickNo", pickNo);
        OkGo.<BaseResponseEntity<T>>get(Constant.b2bPickCheckIbLpn)
                .tag(this)
                .params(map)
                .execute(jsonCallBack);
    }

    public <T> void b2bPickSkuInventoryDetail(String pickNo, String sku, JsonCallBack jsonCallBack) {
        Map<String, String> map = new HashMap<>();
        map.put("sku", sku);
        map.put("pickNo", pickNo);
        OkGo.<BaseResponseEntity<T>>get(Constant.b2bPickSkuInventoryDetail)
                .tag(this)
                .params(map)
                .execute(jsonCallBack);
    }

    public <T> void getInfoByBarcode(String sku, JsonCallBack jsonCallBack) {
        Map<String, String> map = new HashMap<>();
        map.put("sku", sku);
        OkGo.<BaseResponseEntity<T>>get(Constant.getInfoByBarcode)
                .tag(this)
                .params(map)
                .execute(jsonCallBack);
    }

    public <T> void b2bPickSubmit(B2CPickSubmitQr b2CPickSubmitQr, JsonCallBack jsonCallBack) {
        OkGo.<BaseResponseEntity<T>>post(Constant.b2bPickSubmit)
                .tag(this)
                .upJson(GsonUtil.toJson(b2CPickSubmitQr))
                .execute(jsonCallBack);
    }
}